package org.mili.ticketeer.dto;

import java.util.HashMap;
import java.util.Map;

public class Priority extends Identifieable implements Archivable {

    public static enum Fields implements Field {
        PRIORITY,
        NAME;
    }

    public static final String TABLE = "priority";

    private String name;
    private int priority;

    @Override
    public Map<Field, Object> valueMap() {
        Map<Field, Object> map = super.valueMap();
        map.put(Fields.NAME, name);
        map.put(Fields.PRIORITY, priority);
        return map;
    }

    @Override
    public Map<Field, Object> valueMapWithoutId() {
        Map<Field, Object> map = new HashMap<>(valueMap());
        map.remove(Identifieable.Fields.ID);
        return map;
    }

    @Override
    public Map<Field, Object> getUniqueFields() {
        return valueMapWithoutId();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPriority() {
        return priority;
    }

    public void setPriority(int priority) {
        this.priority = priority;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Priority priority1 = (Priority) o;

        if (priority != priority1.priority) return false;
        if (name != null ? !name.equals(priority1.name) : priority1.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + priority;
        return result;
    }

    @Override
    public String toString() {
        return "Priority{" +
                "name='" + name + '\'' +
                ", priority=" + priority +
                '}';
    }
}
